const defaultState = {
    loading: false,
    noteList: [],
    noticeList: [],
    containerOrders: [],
    todayOrderCountAndMoney: {orderCounts: [], fees: []},
    thisMonthOrderCountAndMoney: {orderCounts: [], fees: []},
    countByBusinessType: [],
    countByOriginPlace: [],
    countByName: [],
    lastMonthData: [],
    orderExpiredList: [],
    containerOrderExpiredList: [],
    orderNoCompletedList: [],
    contractExpireList: [],
    daiBanShiXiangList: [],
    logs: [],
    organizations: [],
    clients: [],
    carriers: []
};

export default function home(state = defaultState, action) {
    const {type, payload, error} = action;
    if(error){
        return {...state};
    }
    switch (type) {
        case 'DASHBOARD.DASHBOARD':
            return {...state, dashboardDto: {...payload}};
        case 'DASHBOARD.NOTE_LIST':
            return {...state, noteList: [...payload]};
        case 'DASHBOARD.NOTICE_LIST':
            return {...state, noticeList: [...payload]};
        case 'DASHBOARD.CONTAINER_ORDER':
            return {...state, containerOrders: [...payload]};
        case 'DASHBOARD.TODAYORDERCOUNTANDMONEY':
            return {...state, todayOrderCountAndMoney: {...payload}};
        case 'DASHBOARD.THISMONTHORDERCOUNTANDMONEY':
            return {...state, thisMonthOrderCountAndMoney: {...payload}};
        case 'DASHBOARD.COUNTBYBUSINESSTYPE':
            return {...state, countByBusinessType: [...payload]};
        case 'DASHBOARD.COUNTBYORIGINPLACE':
            return {...state, countByOriginPlace: [...payload]};
        case 'DASHBOARD.COUNTBYNAME':
            return {...state, countByName: [...payload]};
        case 'DASHBOARD.LASTMONTHORDERCOUNTANDAMOUNT':
            return {...state, lastMonthData: [...payload]};
        case 'DASHBOARD.GETORDEREXPIREDLIST':
            return {...state, orderExpiredList: [...payload]};
        case 'DASHBOARD.GETCONTAINERORDEREXPIREDLIST':
            return {...state, containerOrderExpiredList: [...payload]};
        case 'DASHBOARD.GETORDERNOCOMPLETEDLIST':
            return {...state, orderNoCompletedList: [...payload]};
        case 'DASHBOARD.GETCONTRACTEXPIRELIST':
            return {...state, contractExpireList: [...payload]};
        case 'DASHBOARD.DAIBANSHIXIANGDATA':
            return {...state, daiBanShiXiangList: [...payload]};
        case 'DASHBOARD.LOG_LIST':
            return {...state, logs: [...payload]};
        case 'DASHBOARD.ORGANIZATIONS':
            return {...state, organizations: [...payload]};
        case 'DASHBOARD.GET_CLIENT':
            return {...state, clients: [...payload]};
        case 'DASHBOARD.GET_CARRIER':
            return {...state, carriers: [...payload]};
        default:
            return state;
    }
}
